import hashlib


class zaker:
    def gen_webcode(self,_udid, _appid, _v, _version):
        """
        生成ZAKER应用的_webcode参数

        返回:
        生成的_webcode参数（20字符长度）
        """
        # 组合初始字符串
        initial_str = f"{_udid},,{_appid},{_v},{_version}".lower()
        # 连续2次MD5哈希
        result = initial_str
        for _ in range(3):
            result = hashlib.md5(result.encode()).hexdigest().lower()

            # 截断为20字符
        return result[:20]

    def md5(self,str):
        return hashlib.md5(str.encode("utf-8")).hexdigest()
    def gen_flag(self,key, appid, udid, version, timestamp):
        parr = key + appid + udid + version + timestamp
        jiami1 =self.md5(parr)
        jiami2 = self.md5(jiami1)
        return jiami2
if __name__ == '__main__':
    zakerr = zaker()
    _udid="1fb67af59b5699a6"
    _appid="AndroidPhone"
    _v="9.1.5"
    _version="9.08"
    _time="1754548972"
    _webcode=zakerr.gen_webcode(_udid,_appid , _v, _version)
    print(_webcode)
    key="WvT6dYtChFRdb7yKsearch"
    _flag = zakerr.gen_flag(key, _appid, _udid, _version, _time)
    print(_flag)